package util

import (
    "fmt"
    "github.com/gin-gonic/gin"
    "strconv"
)

type UserInfo struct {
    UserID int `json:"user_id,omitempty"`
}

func GetUserInfo(ctx *gin.Context) *UserInfo {
    var user_info UserInfo
    user_id, exist := ctx.Get("user_id")
    if !exist {
        return nil
    }
    UserID, _ := strconv.Atoi(fmt.Sprint(user_id))
    user_info.UserID = UserID
    return &user_info
}